//
//  YDMinePositionTopView.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2017/11/13.
//  Copyright © 2017年 LK-IOS. All rights reserved.
//

#import "YDMinePositionTopView.h"
#import "YDHoldPositionModel.h"
@interface YDMinePositionTopView()
//标题
@property (nonatomic , weak) UILabel *profitLoss;

//盈亏金额
@property (nonatomic , weak) UILabel *profitLossNumber;


@end

@implementation YDMinePositionTopView

-(void)setModel:(YDHoldPositionModel *)model
{
    _model = model;
    
    self.profitLossNumber.text = model.pzHoldProfitOrLoss;
}

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = NumberColor(62, 89, 167);
        
        [self profitLoss];
        
        [self profitLossNumber];
    }
    return self;
}

+(instancetype)minePositionTopViewWithModel:(YDHoldPositionModel *)model
{
    YDMinePositionTopView *topView = [[self alloc] init];
    topView.model = model;
    return topView;
}

-(UILabel *)profitLoss
{
    if (_profitLoss == nil) {
        UILabel *profitLoss = [[UILabel alloc] init];
        [self addSubview:profitLoss];
        profitLoss.textAlignment = NSTextAlignmentLeft;
        profitLoss.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        profitLoss.textColor = [UIColor whiteColor];
        profitLoss.text = @"持仓盈亏（元）";
        [profitLoss  mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(rate375(23));
            if (isPhoneX) {
                make.top.equalTo(self).offset(rateX812(30));
            }else{
                make.top.equalTo(self).offset(rate750(30));
            }
        }];
        
        _profitLoss = profitLoss;
    }
    return _profitLoss;
}


-(UILabel *)profitLossNumber
{
    if (_profitLossNumber == nil) {
        UILabel *profitLossNumber = [[UILabel alloc] init];
        [self addSubview:profitLossNumber];
        profitLossNumber.textAlignment = NSTextAlignmentLeft;
        profitLossNumber.font = [UIFont boldSystemFontOfSize:font32ScreenWRate * LKScreenW];
        profitLossNumber.textColor = [UIColor whiteColor];
        profitLossNumber.text = @"";
        [profitLossNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.profitLoss);
            if (isPhoneX) {
                make.top.equalTo(self.profitLoss.mas_bottom).offset(rateX812(10));
            }else{
                make.top.equalTo(self.profitLoss.mas_bottom).offset(rate750(10));
            }
        }];
        _profitLossNumber = profitLossNumber;
    }
    return _profitLossNumber;
}

@end
